CREATE TABLE [dbo].[TDSERV_FACT]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TDSERV_FA__NU_AN__1F98B2C1] DEFAULT (datepart(year,getdate())),
[CO_SERV_FACT] [dbo].[TD_VC_003] NOT NULL,
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NOT NULL,
[CO_MONE] [dbo].[TD_VC_003] NOT NULL,
[TI_AUXI_EMPR] [dbo].[TD_VC_001] NULL,
[CO_AUXI_EMPR] [dbo].[TD_VC_020] NULL,
[PO_ABON] [dbo].[TD_NU_009_004] NOT NULL CONSTRAINT [DF__TDSERV_FA__PO_AB__22751F6C] DEFAULT ((1.000)),
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TDSERV_FA__FE_US__245D67DE] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TDSERV_FA__FE_US__25518C17] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TDSERV_FACT] ADD CONSTRAINT [CK__TDSERV_FA__CO_CN__2180FB33] CHECK (([CO_CNTA_EMPR]>='0' AND [CO_CNTA_EMPR]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TDSERV_FACT] ADD CONSTRAINT [CK__TDSERV_FA__NU_AN__208CD6FA] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TDSERV_FACT] ADD CONSTRAINT [CK__TDSERV_FA__PO_AB__236943A5] CHECK (([PO_ABON]>=(0)))
GO
ALTER TABLE [dbo].[TDSERV_FACT] ADD CONSTRAINT [XPKTDSERV_FACT] PRIMARY KEY CLUSTERED  ([CO_EMPR], [NU_ANNO], [CO_SERV_FACT], [CO_CNTA_EMPR]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TDSERV_FACT] ADD CONSTRAINT [FK1_TMPLAN_ANNO_A_TDSERV_FACT] FOREIGN KEY ([CO_EMPR], [CO_CNTA_EMPR]) REFERENCES [dbo].[TMPLAN_ANNO] ([CO_EMPR], [CO_CNTA_EMPR])
GO
